package cn.iocoder.yudao.framework.magic.config.interceptor;

import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Component;
import org.ssssssss.magicapi.core.context.RequestEntity;
import org.ssssssss.magicapi.modules.db.BoundSql;
import org.ssssssss.magicapi.modules.db.inteceptor.SQLInterceptor;

import java.util.Arrays;

@Log4j2
public class SQLInterceptorCustom implements SQLInterceptor {

    @Override
    public void preHandle(BoundSql boundSql, RequestEntity requestEntity) {
        log.info("要执行的SQL:" + boundSql.getSql());
        log.info("要执行的SQL参数:" + Arrays.toString(boundSql.getParameters()));
        // 这里也可以通过boundSql的方法改写SQL和参数
    }
}
